package com.slwu.util;

import ch.qos.logback.core.PropertyDefinerBase;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;

public class InsLogDefiner extends PropertyDefinerBase {
    public InsLogDefiner() {
    }

    public String getPropertyValue() {
        RuntimeMXBean runt = ManagementFactory.getRuntimeMXBean();
        String name = runt.getName();
        String[] parts = name.split("@");
        String ip = null;
        if (Boolean.valueOf(System.getProperty("server.hostOverIp", "false"))) {
            ip = NetUtil.getLocalName();
        } else {
            ip = NetUtil.getLocalIp((String)null);
        }

        return ip + "@" + parts[0];
    }
}
